package com.Lyy.Controller;

import com.Lyy.Entity.Student;
import com.Lyy.Service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Component
@RequestMapping("/Student")
@ResponseBody
public class StudentController {
    @Autowired
    private StudentService studentService;

    @GetMapping
    public List<Student> SelectStudentAll() {
        return studentService.SelectStudentAll();
    };
    @GetMapping(params = "studentName")
    public List<Student> SelectStudentByName(String studentName){
        return studentService.SelectStudentByName(studentName);
    }
    @GetMapping("/{id}")
    public Student SelectStudentById(@PathVariable String id){

        return studentService.SelectStudentById(Integer.parseInt(id));
    }
    @DeleteMapping("/{id}")
    public int DeleteStudentById(@PathVariable String studentId){
        return studentService.DeleteStudentById(Integer.parseInt(studentId));
    }

}
